import { RequestUtil } from '@/utils/request.js';

const getList = (pageNo, pageSize, searchQuery, sortBy, isAsc) => {
  return RequestUtil.get('/role', {
    params: {
      pageNo: pageNo,
      pageSize: pageSize,
      sortBy: sortBy,
      isAsc: isAsc,
      ...searchQuery
    }
  });
};

const add = (data) => {
  return RequestUtil.post('/role', { data: data });
};

const update = (id, role) => {
  return RequestUtil.put('/role', {
    data: { roleId: id, ...role }
  });
};

const deleteByIds = (ids) => {
  return RequestUtil.delete('/role?ids=' + (Array.isArray(ids) ? ids.join(',') : ''));
};

export const RoleApi = {
  getList,
  add,
  update,
  deleteByIds
};
